package com.huike.controller;

import com.huike.log.Log;
import com.huike.user.dtos.LoginDTO;
import com.huike.result.Result;
import com.huike.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/user")
@Slf4j
public class UserController {

    @Autowired
    private UserService userService;



    @PostMapping("/list")
    public void list(){
        userService.listUser();
    }

    @PostMapping("/login")
    @Log(title = "用户模块")
    public Result login(@RequestBody LoginDTO dto){
     log.info("用户登录：{}",dto);
     return userService.login(dto);
    }

    /**
     * 下载模版
     * @return
     */
    @Log(title = "用户模块")
    @GetMapping("/download")
    public Result download(){
        return userService.download();
    }
    /**
     * 批量导入用户
     * @param file
     * @return
     */
    @Log(title = "用户模块")
    @PostMapping("/upload")
    public Result upload(MultipartFile file){
        return userService.upload(file);
    }
}
